package com.wdc.service.impl;


import com.wdc.entity.query.SimplePage;
import com.wdc.enums.PageSize;
import com.wdc.entity.vo.PaginationResultVo;
import com.wdc.entity.po.UserBeautyInfo;
import com.wdc.entity.query.UserBeautyInfoQuery;
import com.wdc.mapper.UserBeautyInfoMappers;
import com.wdc.service.UserBeautyInfoService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * @author: WDC
 * @description:Service
 * @date:2024/09/09
 */
@Service("userBeautyInfoService")
public class UserBeautyInfoServiceImpl implements UserBeautyInfoService {


	@Resource
	private UserBeautyInfoMappers<UserBeautyInfo, UserBeautyInfoQuery> userBeautyInfoMappers;

	/**
	 * 根据条件查询列表
	 */
	public List<UserBeautyInfo> findListByParam(UserBeautyInfoQuery query) {
		return this.userBeautyInfoMappers.selectList(query);
	
	}

	/**
	 * 根据条件查询数量
	 */
	public Integer findCountByParam(UserBeautyInfoQuery query) {
		return this.userBeautyInfoMappers.selectCount(query);
	}

	/**
	 * 分页查询
	 */
	public PaginationResultVo<UserBeautyInfo> findListByPage(UserBeautyInfoQuery query) {
		Integer count = this.findCountByParam(query);
		Integer pageSize = query.getPageSize() == null ? PageSize.SIZE15.getSize() : query.getPageSize();
		SimplePage page = new SimplePage(query.getPageNo(), count, pageSize);
		query.setSimplePage(page);
		List<UserBeautyInfo> list = this.findListByParam(query);
		PaginationResultVo<UserBeautyInfo> result = new PaginationResultVo(count, page.getPageSize(), page.getPageNo(), page.getPageTotal(), list);
		return result;
	}

	/**
	 * 新增
	 */
	public Integer add(UserBeautyInfo bean) {
		return this.userBeautyInfoMappers.insert(bean);
	}

	/**
	 * 批量新增
	 */
	public Integer addBatch(List<UserBeautyInfo> listBean) {
		if (listBean == null || listBean.isEmpty()) {
		return 0;
		}
		return this.userBeautyInfoMappers.insertBatch(listBean);	}

	/**
	 * 批量新增或修改
	 */
	public Integer addOrUpdateBatch(List<UserBeautyInfo> listBean) {
		if (listBean == null || listBean.isEmpty()) {
		return 0;
		}
		return this.userBeautyInfoMappers.insertOrUpdateBatch(listBean);	}
	/**
	 * 根据Id查询
	 */
	public UserBeautyInfo getUserBeautyInfoById(Integer id) {
		return this.userBeautyInfoMappers.selectById(id);
	}

	/**
	 * 根据Id更新
	 */
	public Integer updateUserBeautyInfoById(UserBeautyInfo bean, Integer id) {
		return this.userBeautyInfoMappers.updateById(bean, id);
	}

	/**
	 * 根据Id删除
	 */
	public Integer deleteUserBeautyInfoById(Integer id) {
		return this.userBeautyInfoMappers.deleteById(id);
	}

	/**
	 * 根据UserId查询
	 */
	public UserBeautyInfo getUserBeautyInfoByUserId(String userId) {
		return this.userBeautyInfoMappers.selectByUserId(userId);
	}

	/**
	 * 根据UserId更新
	 */
	public Integer updateUserBeautyInfoByUserId(UserBeautyInfo bean, String userId) {
		return this.userBeautyInfoMappers.updateByUserId(bean, userId);
	}

	/**
	 * 根据UserId删除
	 */
	public Integer deleteUserBeautyInfoByUserId(String userId) {
		return this.userBeautyInfoMappers.deleteByUserId(userId);
	}

	/**
	 * 根据Email查询
	 */
	public UserBeautyInfo getUserBeautyInfoByEmail(String email) {
		return this.userBeautyInfoMappers.selectByEmail(email);
	}

	/**
	 * 根据Email更新
	 */
	public Integer updateUserBeautyInfoByEmail(UserBeautyInfo bean, String email) {
		return this.userBeautyInfoMappers.updateByEmail(bean, email);
	}

	/**
	 * 根据Email删除
	 */
	public Integer deleteUserBeautyInfoByEmail(String email) {
		return this.userBeautyInfoMappers.deleteByEmail(email);
	}

}